#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
struct arr {
	char name[20];
	int age;
};
void my_qsort(void *arr,size_t num,size_t sz,int (*fun)(const void* a,const void* b)) {
	for (int a = 0; a < num - 1; a++)
	{
		for (int b = 0; b < num - 1 - a; b++)
		{
			if (fun((char*)arr + b * sz, (char*)arr + (b + 1) * sz)>0)
			{
				for (int c = 0; c < sz; c++)
				{
					char tmp;
					tmp = *((char*)arr + b * sz + c);
					*((char*)arr + b * sz + c) = *((char*)arr + (b + 1) * sz + c);
					*((char*)arr + (b + 1) * sz + c) = tmp;
				}
			}
		}
	}
}
int bijiao(const void* a,const void* b) {
	return ((struct arr*)a)->age - ((struct arr*)b)->age;
}
int main()
{
	struct arr s[3] = { {"fankaige",20},{"zhangchen",21},{"wangyixuan",19} };
	int sz = sizeof(s) / sizeof(s[0]);
	my_qsort(s, 3, sizeof(s[0]), bijiao);
	for (int c = 0; c < 3; c++)
	{
		printf("%s %d\n", s[c].name, s[c].age);
	}
	return 0;
}